-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Fix: Suppress EAI_NODATA error for IPv4/IPv6-only domains #14013
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Fix: Suppress EAI_NODATA error for IPv4/IPv6-only domains #14013
Conversation
This change prevents getaddrinfo() from throwing an error when a domain only has A records (IPv4) or AAAA records (IPv6), which is expected behavior for single-stack domains. Fixes microsoft#13937 and microsoft#13820
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR fixes unnecessary error logging when WSL performs connection checks on domains that only support IPv4 or IPv6. The change suppresses the EAI_NODATA error returned by getaddrinfo() when a domain lacks records for the requested address family (e.g., IPv4-only domains have no AAAA records), which is expected behavior and should not generate error logs.
Key Changes:
- Added special handling for EAI_NODATA error code after
getaddrinfo()calls - Returns an empty socket instead of throwing an exception when EAI_NODATA is encountered
- Connection check continues normally for the available address family while skipping the unavailable one
| auto status = getaddrinfo(hostname, port, &hints, &servinfo); | ||
| if (status != 0) | ||
| { | ||
| if (status == EAI_NODATA) |
Copilot
AI
Jan 2, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
EAI_NODATA is not portable across all platforms. On Windows, EAI_NODATA may not be defined in winsock2.h/ws2tcpip.h. On modern Linux systems, EAI_NODATA is deprecated and some systems use EAI_NONAME instead for the same scenario (no address records for the requested family).
Consider checking for both EAI_NODATA and EAI_NONAME, or wrapping this in platform-specific preprocessor checks to ensure the code compiles and works correctly on all target platforms.
| throw std::runtime_error(std::format("CheckConnection: getaddrinfo() failed: {}", status)); | ||
| } | ||
|
|
||
|
|
Copilot
AI
Jan 2, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Extra blank line added here. This appears to be unintentional formatting change that should be removed to maintain consistency with the existing code style.
|
@copilot open a new pull request to apply changes based on the comments in this thread |
Summary
This PR suppresses EAI_NODATA from getaddrinfo() during connection checks, which occurs for domains that only have A (IPv4) or AAAA (IPv6) records and is expected behavior for single-stack domains.
Instead of throwing (and spamming logs), the code returns an empty socket so the connection attempt is skipped for the missing address family while still allowing checks to proceed normally.
Context / Motivation
WSL may log CheckConnection: getaddrinfo() failed for domains that are IPv4-only or IPv6-only, even though networking continues to work.
This change avoids unnecessary error logs while keeping real failures intact (non-EAI_NODATA errors still throw).
Changes
Handle status == EAI_NODATA right after getaddrinfo() and return an empty socket (unique_socket) instead of throwing.
Change is isolated to src/shared/inc/conncheckshared.h.
Issues
Fixes #13937 and #13820.
Validation steps performed
Ran simple validation on an isolated x64 environment:
Started WSL and verified general connectivity works as expected (internet OK).
Verified IPv6 did not trigger the previous error condition (no IPv6-related error observed).
Confirmed the log spam does not occur after the change for single-stack scenarios.